import unittest
from Finance_fun.page.page06_collection_plan import Page_Collection_Plan
from Finance_fun.base.get_driver import GetDriver
from Finance_fun.tool.read_json import read_json
from parameterized import parameterized


def get_my_collection_plan_data():
    case = read_json("data06_my_collection_plan.json")
    list_null = []
    for data in case.values():
        list_null.append(
            (
                data["repayment_date"],
                data["end_date"],
                data["keyword"]
             )
        )
    return list_null

class MyCollectionPlanTest(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.driver = GetDriver.get_driver()
        cls.my_skjh = Page_Collection_Plan(cls.driver)
        cls.my_skjh.page_click_login_link()
        cls.my_skjh.page_login("15390197897","cf12345678")


    @classmethod
    def tearDownClass(cls):
        GetDriver.quit_driver()

    @parameterized.expand(get_my_collection_plan_data())
    def test01_my_skjh(self,repayment_date,end_date,keyword):
        self.my_skjh.my_skjh()
        self.my_skjh.input_hk(repayment_date)
        self.my_skjh.check_end_date(end_date)
        self.my_skjh.my_collection_plan(keyword)
        self.my_skjh.click_filter_btn()
